<template>
	<view>
		<view v-for="(item,index) in res" :key="index" class="list">
			<view class="time" v-cloak>{{item.createtime}}</view>
			<div class="cont webkit">
				<image :src="item.thumb"></image>
				<view class="inner flex">
					<view class="top" v-cloak>{{item.title}}</view>
					<view class="bottom">
						<text class="marketprice" v-cloak>¥{{item.marketprice}}</text>
						<text class="productprice" v-cloak>¥{{item.productprice}}</text>
					</view>
				</view>
			</div>
		</view>
		<uni-load-more v-if="load == 1"  :loadingType="loadingType" :contentText="contentText"></uni-load-more>
	</view>
</template>
<script>
	import uniLoadMore from '../../components/uni-load-more.vue'
	export default {
		data() {
			return {
				res:[],
				index:2,
				load:0,
				loadingType:0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多了"
				},
				openid:''
			};
		},
		onLoad:function(){
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		methods:{
			setAjax(){
				uni.request({
					url: 'http://wx.mygodmall.com/app/index.php?i=5&c=entry&m=ewei_shopv2&do=mobile&r=member.history.get_list&app=1&page=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						this.res = res.data.result.list;
						if(res.data.result.total > res.data.result.pagesize){
							this.load = 1
						}
						uni.hideLoading();
					},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		onReachBottom(){
			if (this.loadingType !== 0) {
				return;
			}
			this.loadingType = 1;
			uni.request({
				url: 'http://wx.mygodmall.com/app/index.php?i=5&c=entry&m=ewei_shopv2&do=mobile&r=member.history.get_list&app=1&page='+this.index,
				method: 'POST',
				data: {
					'openid':this.openid
				},
				header:{'Content-Type':'application/x-www-form-urlencoded'},
				success: res => {
					if(res.data.result.list.length == 0){
						this.loadingType = 2;
						return;
					}
					this.res = this.res.concat(res.data.result.list)
					this.loadingType = 0;
					this.index = this.index + 1;
				},
				fail: () => {},
				complete: () => {}
			});
			
		},
		components: {uniLoadMore}
	}
</script>

<style>.list{background:#fff;margin-bottom:20upx;}.time{line-height:72upx;padding:0 24upx;border-bottom:1px solid #ebebeb;}.cont{padding:26upx 24upx;}.cont image{width:160upx;height:160upx;margin-right:24upx;}.top{height:120upx;}.bottom{height:40upx;}.bottom text{font-size:28upx;}.marketprice{color:#f55;}.productprice{color:#999;text-decoration:line-through;}</style>